Class BinarySearchTree<T extends TreeNodeInfo>
java.lang.Object
edu.claflin.finder.algo.clustering.struct.BinarySearchTree<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAddd a new Tree Node with the given j index and q valueprivate voidRecursive implementation of add.booleanasList()private voidvoidclear()booleanIs the specified ElemntType in the BinarySearchTree?private booleanprivate voidTime complexity: O(n)private voidTime complexity: O(n)voidDSW()intprivate intgetMax()getMin()private Tprivate intgreatestPowerOf2LessThanN(int n) .booleanisEmpty()Is the BinarySearchTree empty?private voidmakeRotations(int bound) voidmergeTrees(BinarySearchTree<T> that) private voidmergeTrees(BinarySearchTree<T> that, TreeNode<T> p) intMSB(int n) Return the index of most significant set bit: index of least significant bit is 0.voidprivate voidvoidtoString()Gets an inorder String representation of the BinarySearchTree.private StringRecursive implementation of inorder toString.
-
Field Details
-
root
-
allow_duplicates
private boolean allow_duplicates
-
-
Constructor Details
-
BinarySearchTree
public BinarySearchTree()Create an empty BinarySearchTree. -
BinarySearchTree
public BinarySearchTree(boolean dup)
-
-
Method Details
-
allows_duplicates
public boolean allows_duplicates() -
isEmpty
public boolean isEmpty()Is the BinarySearchTree empty?- Returns:
- true if empty, false otherwise
-
clear
public void clear() -
add
Addd a new Tree Node with the given j index and q value- Parameters:
info- the key
-
add
Recursive implementation of add.- Parameters:
info- the keyp- the current top Tree Node
-
getVal
-
get
-
get
-
set
-
contains
Is the specified ElemntType in the BinarySearchTree?- Parameters:
info- the key- Returns:
- true if it is contained, false otherwise
-
contains
-
toString
Gets an inorder String representation of the BinarySearchTree. -
toString
Recursive implementation of inorder toString.- Parameters:
p- the current TreeNode to print and recursive parameter- Returns:
- the BinarySearchTree as a String
-
getMin
-
getMin
-
getMax
-
getMax
-
remove
-
remove
-
getHeight
public int getHeight() -
getHeight
-
DSW
public void DSW() -
createBackbone
private void createBackbone()Time complexity: O(n) -
rotateRight
-
createPerfectBST
private void createPerfectBST()Time complexity: O(n) -
greatestPowerOf2LessThanN
private int greatestPowerOf2LessThanN(int n) . Time complexity: log(n)- Parameters:
n- the inout number- Returns:
- the greatest power of 2 less than N
-
MSB
public int MSB(int n) Return the index of most significant set bit: index of least significant bit is 0. Time complexity: log(n)- Parameters:
n- the input number- Returns:
- the index of most significant set bit
-
makeRotations
private void makeRotations(int bound) -
rotateLeft
-
mergeTrees
-
mergeTrees
-
asList
-
asList
-